package com.diandi.log;

import com.alibaba.fastjson.JSONObject;
import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 * feign  interceptor 需要通过外部注入
 *
 * @Bean
 * public DDFeignRequestInteceptor ddFeignRequestInteceptor(){
 * return new DDFeignRequestInteceptor();
 * }
 * Created by 袁恩光 on 2018/1/5.
 */
public class DDFeignRequestInteceptor implements RequestInterceptor {

    /**
     * 对feign 每次请求做log信息的传递
     * json 格式
     */
    @Override
    public void apply(RequestTemplate requestTemplate) {
        requestTemplate.query(LogTemp.NEXT_LOG_DATA, JSONObject.toJSONString(LogTemp.LOG_TITLE_MESSAGE.get()));
    }

}
